package com.qf.day2;

import java.util.Random;
import java.util.Scanner;

public class Work1 {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        //生成的随机数
        int i = random.nextInt(10000 - 2000) + 2000 + 1;
        System.out.println(i);
        //五次机会
        boolean flag = true;
        for (int j = 0; j < 5; j++) {
            System.out.print("请输入答案:");
            int result = scanner.nextInt();
            if(result == i){
                System.out.println("恭喜你,获得了此奖品");
                flag = false;
                break;
            }
        }
        //五次结束
        if(flag){
            System.out.println("很可惜你没有获得奖品");
        }
    }
}
